package com.ccy.socket;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import com.ccy.utils.IoUtils;
import com.ccy.utils.Log;

public class ServerSocketTest {

	public static void main(String[] args) {
		ServerSocket server = null;
		try {
			server = new ServerSocket(80);
			Socket socket = null;
			while (true) {
				try {
					socket = server.accept();
				} catch (IOException e) {
					Log.e("Socket:may be timeout");
				} finally {
					IoUtils.closeSilently(socket);
				}
			}
		} catch (IOException e) { // BindException
			Log.e("Server:port had been use");
		} finally {
			IoUtils.closeSilently(server);
		}
	}
}